﻿using System;
using System.Collections.Generic;
using System.Text;
using OgilvyOne.UKNow.Model;
using OgilvyOne.UKNow.DALFactory;
using ECCIT;
using System.Linq;
using OgilvyOne.UKNow.IDAL;
using OgilvyOne.UKNow.DAL;

namespace OgilvyOne.UKNow.BLL
{
    public class EventsCommentBLL
    {
        /*修改人：穆凤凤
       * 修改时间：2012-01-03
       * 修改内容：
       *      新增加方法, 根据活动的ID(评论表中的一部分评论的所有信息)获取该活动的所有的评论的所有信息
       *      有mff注释的为本次修改的代码
       */
        //mff
        public int LanguageID { get; set; }
        public EventsCommentBLL(int langID)
        {
            this.LanguageID = langID;
        }
        //新增评论
        public ResultInfo Save(EventsCommentModel info)
        {
            IDALEventsComment use = EventsCommentDALFactory.Create(LanguageID);
            return use.Save(info);
        }
        //根据评论ID获取该评论的所有信息
        public EventsCommentModel selEvent(int Comment_ID)
        {
            IDALEventsComment use = EventsCommentDALFactory.Create(LanguageID);
            return use.GetEventsCommentModelByID(Comment_ID);
        }

        //mff
        /*修改人：穆凤凤
        * 修改时间：2012-04-18
        * 修改内容：
        *      新增方法 获得按用户ID,获得活动评论数据的方法 SelEventCommentByUserID,(用于接口)
        *      有mff注释的为本次修改的代码
        */
        public IList<EventsCommentModel> SelEventCommentByUserID(int userID)
        {
            IDALEventsComment use = EventsCommentDALFactory.Create(LanguageID);
            return use.GetEventCommentByUserID(userID);

        }

        //根据活动的ID(评论表中的一部分评论的所有信息)获取该活动的所有的评论的所有信息
        public IList<EventsCommentModel> selectcommentbyeventID(int Event_ID)
        {
            IDALEventsComment use = EventsCommentDALFactory.Create(LanguageID);
            return use.GetEventsCommentModelsByEventsID(Event_ID);
            
        }
        //mff


        /*修改人：穆凤凤
      * 修改时间：2012-01-13
      * 修改内容：
      *      新增加方法, 根据评论ID删除评论的信息
      *      有mff注释的为本次修改的代码
      */
        //mff
        //删除单个评论的数据(目前页面过来的id是 string)
        public ResultInfo delComment(int eid)
        {
            IList<int?> list = new List<int?>();
            list.Add(eid);
            IDALEventsComment use = EventsCommentDALFactory.Create(LanguageID);
            return use.Delete(list);
        }
        ////修改个单个评论的发布状态
        //public void modPubOne(int eid)
        //{
        //    List<int?> list = new List<int?>();
        //    list.Add(eid);

        //    IDALEventsComment use = EventsCommentDALFactory.Create(LanguageID);

        //    EventsCommentModel model = use.GetEventsCommentModelByID(eid); //查看该评论的当前发布状态
        //    if (model.State > 0) //该评论的当前为发布状态
        //    {
        //        use.UnPublish(list);
        //        //设置为该评论的state为0 不发布 (传递参数 eid 和 int=0)
        //    }
        //    else
        //    {
        //        use.Publish(list);
        //        //设置该评论的state为1 发布     (传递参数 eid 和 int=1)
        //    }
        //}
        //mff
        /// <summary>
        ///     获取某个活动的所有已发布评论数据，默认根据最后修改时间倒排序
        /// </summary>
        /// <param name="warmupID">作品id</param>
        /// <param name="pagingParams">分页和排序参数</param>
        /// <returns></returns>
        public PagingList getEventsCommentPage(int eventsid,PagingParameter PagingParameters)
        {
            return EventsCommentDALFactory.Create(LanguageID).GetPublishedCommentsByEventsID(eventsid, PagingParameters);
        }

        public PagingList GetEventsCommentsWithImageByUserID(int? userID, PagingParameter pagingParams)
        {
            return EventsCommentDALFactory.Create(LanguageID).GetEventsCommentsWithImageByUserID(userID, pagingParams);
        }

        #region 根据用户ID获取该用户的评论数据
        /// <summary>
        /// 根据用户ID获取该用户的评论数据
        /// </summary>
        /// <param name="memberID">用户ID</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSzie">每页显示个数</param>
        /// <returns></returns>
        public PagingList GetEventCommentsByMemberID(int? memberID,int pageIndex,int pageSzie)
        {
            PagingParameter paginParams = PagingParameterFactory.CreateInstance(true, pageIndex, pageSzie, null);
            return EventsCommentDALFactory.Create(LanguageID).GetEventCommentsByMemberID(memberID, paginParams);
 
        }

       /// <summary>
       /// 更新评论内容(删除评论）
       /// </summary>
       /// <param name="model"></param>
       /// <returns></returns>
 
       public ResultInfo Update(EventsCommentModel model)
       {
           return EventsCommentDALFactory.Create(LanguageID).Update(model);
       }
       public PagingList getAllPulishedCommons(PagingParameter pagingParams, int? userID)
       {
           return EventsCommentDALFactory.Create(LanguageID).getALLMod(pagingParams, userID);
       }

       public PagingList GetEventsCommentModelsByEventsID(int? eventsID, PagingParameter pagingParams)
       {
           return EventsCommentDALFactory.Create(LanguageID).GetEventsCommentModelsByEventsID(eventsID, pagingParams);
       }
        #endregion
    }
}
